var fs = require('fs'),
    path = require('path');

let errorJSON = [];
const error = async (content) => {
    let data = fs.readFileSync(path.join(__dirname, '..', '/json/error.json'), 'utf-8');
    try{
        errorJSON = JSON.parse(data);
    }catch(e){
        errorJSON = [];
    }
    errorJSON.push(content);
    errorJSON = JSON.stringify(errorJSON);
    fs.writeFileSync(path.resolve(__dirname, '../json/error.json'), errorJSON);
    return {
        msg: "success"
    }
}

module.exports = error;